package com.yinquan.util;

import java.util.ArrayList;
import java.util.List;

import com.yishun.springboot.dao.CWRServiceTest;

import lombok.extern.slf4j.Slf4j;

/**
 * 公共转换controll接收的参数 例如:sort name currpage
 * 
 * @author Administrator
 *
 */

@Slf4j
public class publicConversion {

	public static void main(String[] args) {
		log.info(generalSort("ascending"));
	}

	public static String generalName(String name) {
		if (name == null)
			name = "";
		return name;
	}

	public static String generalSort(String sort) {
		if (sort == null)
			sort = "";
		if (sort.equals("descending"))
			sort = "desc";
		if (sort.equals("ascending"))
			sort = "asc";
		return sort;
	}
	public static int generalCurrPage(Object currpage) {
		int conversionVpage = 0;
		if(currpage instanceof Integer) return (int)currpage;
		if(currpage instanceof String) {
		try {
			log.info("INFO:前端String参数currpage传回后台开始转换为INT:");
			conversionVpage = Integer.parseInt(String.valueOf(currpage));
		} catch (NumberFormatException e) {
			log.info("INFO:转换出现异常，值为" + conversionVpage);
		}
		
		}
		return conversionVpage;
	}

}
